<?php

declare(strict_types=1);

/**
 * 登录、注册
 * @author chenshubo
 */
namespace App\Controller\Shop;

use App\Service\Qrcode\VerifyImg;
use App\Model\PssModel\BusinessUser;
use App\Service\Sms\SendSmsCode;
use Hyperf\HttpServer\Contract\RequestInterface;

class UserController extends AbstractController
{
    /**
     * 登录接口
     */
    public function UserLogin(RequestInterface $request)
    {
        return BusinessUser::instance()->login($request->all());
    }
    
    /**
     * 获取验证码图片
     */
    public function getVerifyImage(RequestInterface $request)
    {
        $uuid = $request->input('uuid');
        $type = $request->input('type');
        $verify_key = $uuid.'_'.$type;
        return VerifyImg::instance()->getQrcodeImg($verify_key);
    }
    
    /**
     * @退出
     */
    public function logout(RequestInterface $request)
    {
        $token = $request->post('token');
        return BusinessUser::instance()->clearCache($token);
    }
    
    /**
     * 注册保存数据接口
     */
    public function userRegisterSave(RequestInterface $request)
    {
        $param = $request->post();
        return BusinessUser::instance()->userRegister($param);
    }
    
    /**
     * 发送验证码
     * @return
     */
    public function sendSmsCode(RequestInterface $request) 
    {
        $param = $request->post();
        return SendSmsCode::instance()->sendMessage($param);
    }
    
    /**
     * 发送短信验证
     */
    public function verifyUser(RequestInterface $request)
    {
        $param = $request->post();
        return BusinessUser::instance()->verifyUser($param);
    }
    
    /**
     * 重置密码
     */
    public function reSetPassword(RequestInterface $request)
    {
        $param = $request->post();
        return BusinessUser::instance()->reSetPassword($param);
    }
}
